package com.dongke.service.Impl;

import com.dongke.mapper.User1Mapper;
import com.dongke.mapper.UserMapper;
import com.dongke.pojo.User;
import com.dongke.pojo.User1;
import com.dongke.pojo.User1Example;
import com.dongke.pojo.UserExample;
import com.dongke.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class UserServiceImpl implements UserService {

    @Autowired
    private User1Mapper user1Mapper;
    @Autowired
    private UserMapper userMapper;
    @Override
    public User1 selectUser(User1 user) {
        User1Example user1Example = new User1Example();
        User1Example.Criteria criteria = user1Example.createCriteria();
        if(user.getUname() != null){
            criteria.andUnameEqualTo(user.getUname());
            List<User1> users = user1Mapper.selectByExample(user1Example);
            if(users == null || users.size() == 0){
                return null;
            }else{
                return users.get(0);
            }
        }
        return null;
    }

    @Override
    public void updateUser(User list) {
        userMapper.updateByPrimaryKeySelective(list);
    }

    @Override
    public void insertinto(User user) {
        userMapper.insertSelective(user);
    }
}
